//
//  GameDetailTableViewCell_Introduction.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2022/9/3.
//

#import "GameDetailTableViewCell_Introduction.h"

@interface GameDetailTableViewCell_Introduction ()

@property (weak, nonatomic) IBOutlet UIView *signView;
@property (weak, nonatomic) IBOutlet UILabel *cellText;

@end

@implementation GameDetailTableViewCell_Introduction

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)initCellData:(GameDetailNewModel *)detailModel
{
    [self.signView removeAllSubviews];
    UIView *temsignOneView = nil;
    for (NSString *signStr in detailModel.gameTypes) {
        UIView *signOneView = [[UIView alloc] init];
        signOneView.backgroundColor = kRGBColor(245, 245, 245);
        signOneView.layer.cornerRadius = 4;
        signOneView.layer.masksToBounds = YES;
        [self.signView addSubview:signOneView];
        UILabel *signLabel = [[UILabel alloc] init];
        signLabel.text = signStr;
        signLabel.font = [UIFont systemFontOfSize:14];
        signLabel.textColor = kColor888888;
        [signOneView addSubview:signLabel];
        [signOneView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.signView);
            if (temsignOneView) {
                make.left.equalTo(temsignOneView.mas_right).offset(5);
            } else {
                make.left.equalTo(self.signView).offset(20);
            }
        }];
        [signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(signOneView);
            make.top.equalTo(signOneView).offset(2);
            make.left.equalTo(signOneView).offset(3);
        }];
        temsignOneView = signOneView;
    }
    
    self.cellText.text = detailModel.gameIntroduce;

}

+(CGFloat)height:(GameDetailNewModel *)detailModel
{
    CGFloat textHeight = 67;
    if (detailModel.isOpen_Introduce) {
        textHeight = [detailModel.gameIntroduce boundingRectWithSize:CGSizeMake(SL_WINDOW_WIDTH - 28, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14]} context:nil].size.height+1;
    }
    
    return 40 + 10 + textHeight + 10;
}

@end
